import request from '@/utils/request'
import qs from 'qs'
// 获取所有菜单（按层级）
export const getMenuNodeList = () => {
  return request({
    method: 'GET',
    url: '/boss/menu/getMenuNodeList'
  })
}
// 获取所有菜单
export const getMenuList = () => {
  return request({
    method: 'GET',
    url: '/boss/menu/getAll'
  })
}
// 根据id查询菜单
export const getMenuById = id => {
  return request({
    method: 'GET',
    url: `/boss/menu/${id}`
  })
}
// 新增或更新菜单
export const addOrUpdateMenu = data => {
  return request({
    method: 'POST',
    url: '/boss/menu/saveOrUpdate',
    data
  })
}
// 删除菜单
export const deleteMenu = id => {
  return request({
    method: 'DELETE',
    url: `/boss/menu/${id}`
  })
}
// 获取角色菜单权限
export const getRoleMenuNodeList = data => {
  console.log(qs.stringify(data))
  return request({
    method: 'GET',
    url: '/boss/menu/getRoleMenus',
    params: data
  })
}
// 给角色分配菜单权限
export const allocRoleMenu = data => {
  return request({
    method: 'POST',
    url: '/boss/menu/allocateRoleMenus',
    data
  })
}
